package hotgammon.view.tools;

import hotgammon.domain.*;
import hotgammon.view.*;
import hotgammon.view.figures.*;

import java.awt.event.MouseEvent;
import java.util.Iterator;
import java.util.List;

import minidraw.framework.*;
import minidraw.standard.*;

/** Tool to specifically to roll dices
 * 
 * Author Jim-Kyrre Benjaminsen
*/

public class DieRollTool extends NullTool  {
  private BackgammonUserInterface objectServer;
  public DieRollTool(BackgammonUserInterface ui) {
    this.objectServer = ui;
  }
  
  public void mouseDown(MouseEvent e, int x, int y) {
    // check that you click on the dice
    Figure f = objectServer.getEditor().drawing().findFigure(e.getX(), e.getY());
    if (f instanceof DieFigure) { 
    	objectServer.getEditor().drawing().lock();
    		objectServer.getGame().nextTurn();
    		System.out.println("Dice thrown [ "+objectServer.getGame().getLastDiceThrown()[0]+" , "+objectServer.getGame().getLastDiceThrown()[1]+" ]");
    	objectServer.getEditor().drawing().unlock();
    } 
  }

}
